#include <iostream>
#include <string>
using namespace std;
char a[105][105];
int b[105][105] = {0};
int n, m;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cin >> n >> m;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
        {
            cin >> a[i][j];
            if (a[i][j] == '*')
            {
                b[i + 1][j] += 1;
                b[i - 1][j] += 1;
                b[i][j + 1] += 1;
                b[i][j - 1] += 1;
                b[i + 1][j + 1] += 1;
                b[i + 1][j - 1] += 1;
                b[i - 1][j + 1] += 1;
                b[i - 1][j - 1] += 1;
            }
        }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
            if (a[i][j] == '*')
                cout << a[i][j];
            else
                cout << b[i][j];
        cout << endl;
    }
}